public class HomeWork05_03{
    public static void main(String[] args){
        int ans = 0;
        int count = 0;
        for(int i = 1; i <= 1000; i++){
            ans += i;
            if(ans % 10 == 8){
                count += 1;
            }
        }
        System.out.println("1 + 2 + ... + 1000 = " + ans + 
                           "\n每步结果中有" + count + "个最后以8结尾的");
    }
}